import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import DataVVue3 from '@kjgl77/datav-vue3'
import './assets/main.css'
import vue3SeamlessScroll from "vue3-seamless-scroll";
import VueAutoScroll from '@fcli/vue-auto-scroll';
import ElementPlus from 'element-plus'

import 'element-plus/dist/index.css'

console.log('应用初始化开始')
const app = createApp(App)
const pinia = createPinia()

app.use(pinia)
app.use(router)
app.use(DataVVue3)
app.use(VueAutoScroll)
app.use(ElementPlus)
app.use(vue3SeamlessScroll)

// 确保应用挂载后立即导航到首页
app.mount('#app').$nextTick(() => {
  console.log('应用挂载完成，开始导航到首页')
  // 使用我们添加的方法进行初始导航
  router.navigateToHome()

  // 显式挂载应用和路由实例到window对象，便于调试和防止Tree Shaking
  window.vueApp = app
  window.vueRouter = router
})
console.log('应用初始化结束')
